package com.jlpay.openapi.demo.ledger.merchconf;

import com.jlpay.open.jlpay.sdk.java.model.ledger.request.MerchIssueOpenRequest;
import com.jlpay.open.jlpay.sdk.java.model.ledger.response.MerchIssueOpenResponse;
import com.jlpay.open.jlpay.sdk.java.utils.json.JsonUtils;
import com.jlpay.openapi.demo.JlpayOpenApiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Arrays;

/**
 *
 * @author dengwenning
 * @since 2024/8/30
 **/
public class MerchIssueOpenService {

    private static final Logger LOGGER = LoggerFactory.getLogger(MerchIssueOpenService.class);

    public static void main(String[] args) {
        MerchIssueOpenRequest merchIssueOpenRequest = buildMerchFileUploadRequest();
        MerchIssueOpenResponse merchIssueOpenResponse = JlpayOpenApiService.openMerchService()
                .post(merchIssueOpenRequest, MerchIssueOpenResponse.class);
        LOGGER.info("分账配置出账方注册响应:{}", JsonUtils.toString(merchIssueOpenResponse));
    }

    private static MerchIssueOpenRequest buildMerchFileUploadRequest() {
        MerchIssueOpenRequest merchIssueOpenRequest = new MerchIssueOpenRequest();
        merchIssueOpenRequest.setOrgCode("50720711");
        merchIssueOpenRequest.setMchId("849581183510017");
        merchIssueOpenRequest.setLedgerModule("02");
        merchIssueOpenRequest.setMaxSplitRate(20);
        merchIssueOpenRequest.setSourceIds(Arrays.asList("jlpay/2024-08-30/e22bc590f433418483626fded04f3362.png", "jlpay/2024-08-30/e22bc590f433418483626fded04f3363.png"));
        merchIssueOpenRequest.setFeeRate(2);
        merchIssueOpenRequest.setPbthf("0");
        merchIssueOpenRequest.setLowAmt(1);
        merchIssueOpenRequest.setUpAmt(10);
        merchIssueOpenRequest.setNotifyUrl("https://api.mch.weixin.qq.com/sns/notify");
        return merchIssueOpenRequest;
    }
}
